import 'package:guochaoapp/model/benchmark_entity.dart';

benchmarkEntityFromJson(BenchmarkEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new List<BenchmarkData>();
		(json['data'] as List).forEach((v) {
			data.data.add(new BenchmarkData().fromJson(v));
		});
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> benchmarkEntityToJson(BenchmarkEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] =  entity.data.map((v) => v.toJson()).toList();
	}
	data['sign'] = entity.sign;
	return data;
}

benchmarkDataFromJson(BenchmarkData data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['createAt'] != null) {
		data.createAt = json['createAt'].toString();
	}
	if (json['changeSymbol'] != null) {
		data.changeSymbol = json['changeSymbol'].toString();
	}
	if (json['changeTotal'] != null) {
		data.changeTotal = json['changeTotal'] is String
				? double.tryParse(json['changeTotal'])
				: json['changeTotal'].toDouble();
	}
	if (json['currentBenchmark'] != null) {
		data.currentBenchmark = json['currentBenchmark'] is String
				? double.tryParse(json['currentBenchmark'])
				: json['currentBenchmark'].toDouble();
	}
	return data;
}

Map<String, dynamic> benchmarkDataToJson(BenchmarkData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['createAt'] = entity.createAt;
	data['changeSymbol'] = entity.changeSymbol;
	data['changeTotal'] = entity.changeTotal;
	data['currentBenchmark'] = entity.currentBenchmark;
	return data;
}